package web.fabrimind.wms.service.impl;

import java.util.List;
import web.fabrimind.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import web.fabrimind.wms.mapper.WarehouseLocationMapper;
import web.fabrimind.wms.domain.WarehouseLocation;
import web.fabrimind.wms.service.IWarehouseLocationService;

/**
 * 仓库库位Service业务层处理
 * 
 * @author zhihui
 * @date 2025-03-28
 */
@Service
public class WarehouseLocationServiceImpl implements IWarehouseLocationService 
{
    @Autowired
    private WarehouseLocationMapper warehouseLocationMapper;

    /**
     * 查询仓库库位
     * 
     * @param locationId 仓库库位主键
     * @return 仓库库位
     */
    @Override
    public WarehouseLocation selectWarehouseLocationByLocationId(Long locationId)
    {
        return warehouseLocationMapper.selectWarehouseLocationByLocationId(locationId);
    }

    /**
     * 查询仓库库位列表
     * 
     * @param warehouseLocation 仓库库位
     * @return 仓库库位
     */
    @Override
    public List<WarehouseLocation> selectWarehouseLocationList(WarehouseLocation warehouseLocation)
    {
        return warehouseLocationMapper.selectWarehouseLocationList(warehouseLocation);
    }

    /**
     * 新增仓库库位
     * 
     * @param warehouseLocation 仓库库位
     * @return 结果
     */
    @Override
    public int insertWarehouseLocation(WarehouseLocation warehouseLocation)
    {
        warehouseLocation.setCreateTime(DateUtils.getNowDate());
        return warehouseLocationMapper.insertWarehouseLocation(warehouseLocation);
    }

    /**
     * 修改仓库库位
     * 
     * @param warehouseLocation 仓库库位
     * @return 结果
     */
    @Override
    public int updateWarehouseLocation(WarehouseLocation warehouseLocation)
    {
        warehouseLocation.setUpdateTime(DateUtils.getNowDate());
        return warehouseLocationMapper.updateWarehouseLocation(warehouseLocation);
    }

    /**
     * 批量删除仓库库位
     * 
     * @param locationIds 需要删除的仓库库位主键
     * @return 结果
     */
    @Override
    public int deleteWarehouseLocationByLocationIds(Long[] locationIds)
    {
        return warehouseLocationMapper.deleteWarehouseLocationByLocationIds(locationIds);
    }

    /**
     * 删除仓库库位信息
     * 
     * @param locationId 仓库库位主键
     * @return 结果
     */
    @Override
    public int deleteWarehouseLocationByLocationId(Long locationId)
    {
        return warehouseLocationMapper.deleteWarehouseLocationByLocationId(locationId);
    }

    /**
     * 查询所属仓库列表（不分页）
     */
    @Override
    public List<WarehouseLocation> selectWarehouseList(WarehouseLocation warehouseLocation) {
        return warehouseLocationMapper.selectWarehouseList(warehouseLocation);
    }
}
